<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="..\..\node_modules\vue\dist\vue.js"></script>
    <script src="..\..\node_modules\axios\dist\axios.js"></script>
</head>
<body>

<div id="app">

    <test-component v-bind:todo="123">
        slot {{cc}} {{todo}}
    </test-component>

</div>

</body>
<script type="application/javascript">
    Vue.component(
        'test-component',
        {
            template:`<p>
            {{content}}<br>
            <slot></slot> {{cc}} </p>
            `,
            props: ['todo'],
            data:function(){
              return {
                  content:this.todo,
                  cc:"abc"
              };
            },
            created: function () {
                // 先拿到component，否则在axios中拿到的this不是component.
                var c = this;
                axios({
                    method:"get",
                    url:"/test_vue/html/axios/package.json",
                    baseURL: 'http://localhost:63342',
                    validateStatus: function (status) {
                        return status >= 200 && status < 300; // 默认值
                    }
                }).then(function (response) {
                        // 处理成功情况
                        console.log("response");
                        console.log(response);
                        c.content = response.data;
                }).catch(function (error) {
                        // 处理错误情况
                        console.log("error");
                        console.log(error);
                }).then(function () {
                        console.log("final");
                });
            },
        }
    );

    var app = new Vue({
        el: '#app',
        data: {
            cc:'cccccccccccccccccccc'
        }
    });

</script>
</html>
